package com.weiyuwqj.server.service.reward.impl;

import com.github.pagehelper.PageHelper;
import com.weiyuwqj.server.service.base.BaseServiceImpl;
import com.weiyuwqj.server.mapper.BasCouponMapper;
import com.weiyuwqj.api.service.BasCouponService;
import com.weiyuwqj.api.common.PageList;
import com.weiyuwqj.api.common.Paginator;
import com.weiyuwqj.api.model.BasCoupon;
import com.weiyuwqj.api.model.vo.BasCouponVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2015/12/2.
 */
@Service("couponService")
public class BasCouponServiceImp extends BaseServiceImpl<BasCoupon> implements BasCouponService {
    @Autowired
    BasCouponMapper couponManagerMapper;


    @Override
    public PageList getList(Paginator p, Map param) {
        PageHelper.startPage(p.getPageNum(), p.getPageSize());
        return new PageList( couponManagerMapper.getList(param));
    }

    @Override
    public List<BasCouponVo> getList(Map param) {
        return couponManagerMapper.getList(param);
    }


    //根据userId查询红包列表

    @Override
    public BasCouponVo getSingle(Integer id) {
        return couponManagerMapper.getSingle(id);
    }

    @Override
    public PageList getDailyList(Paginator p, Map<String, Object> map) {
        PageHelper.startPage(p.getPageNum(), p.getPageSize());
        List<BasCoupon> list=couponManagerMapper.getDailyList(map);
        return new PageList(list);
    }

    //前台投资根据金额对应能使用的红包列表
    @Override
    public List<BasCoupon> getListByUserId(Map map) {
        return couponManagerMapper.getListByUserId(map);
    }

    @Override
    public int updateCouponTimerStatus(Map map) {
        return couponManagerMapper.updateCouponTimerStatus(map);
    }

    @Override
    public PageList listCouponAndConf(Paginator p, Map map) {
        PageHelper.startPage(p.getPageNum(),p.getPageSize());
        List<BasCouponVo> list = couponManagerMapper.listCouponAndConf(map);
        return new PageList(list);
    }

}
